// StartScreen.qml - 开始/主菜单界面
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts

Rectangle {
    color: "#f8f9fa"  // 背景颜色

    // 背景装饰元素 - 与注册界面相同的装饰风格
    Rectangle {
        width: 300
        height: 300
        radius: width / 2
        color: "#e3f2fd"
        opacity: 0.6
        x: -width / 3
        y: -height / 3
    }

    Rectangle {
        width: 200
        height: 200
        radius: width / 2
        color: "#bbdefb"
        opacity: 0.4
        x: parent.width - width / 2
        y: parent.height - height / 2
    }

    // 主布局
    ColumnLayout {
        anchors.centerIn: parent
        width: Math.min(parent.width * 0.8, 400)
        spacing: 25  // 较大的间距

        // 标题区域
        ColumnLayout {
            Layout.alignment: Qt.AlignHCenter
            spacing: 5

            // 视频图标
            Image {
                Layout.alignment: Qt.AlignHCenter
                source: "qrc:/images/video-icon.svg" // 视频图标路径
                sourceSize.width: 70
                sourceSize.height: 70
                fillMode: Image.PreserveAspectFit

                // 图标加载失败时的备用文本
                Text {
                    visible: parent.status === Image.Error || parent.source === ""
                    text: "🎥"  // 摄像机表情符号
                    font.pixelSize: 45
                    anchors.centerIn: parent
                }
            }

            // 主标题
            Text {
                text: qsTr("视频会议")
                font.pixelSize: 28
                font.weight: Font.Bold
                color: "#2c3e50"
                Layout.alignment: Qt.AlignHCenter
            }

            // 副标题
            Text {
                text: qsTr("选择您要进行的操作")
                font.pixelSize: 14
                color: "#7f8c8d"
                Layout.alignment: Qt.AlignHCenter
            }
        }

        // 按钮区域
        ColumnLayout {
            spacing: 15
            Layout.fillWidth: true

            // 创建会议按钮
            Button {
                id: createBtn
                Layout.fillWidth: true
                text: qsTr("创建会议")
                font.pixelSize: 16
                font.weight: Font.Medium
                padding: 15

                // 蓝色按钮样式
                background: Rectangle {
                    radius: 8
                    color: createBtn.down ? "#2980b9" : "#3498db"  // 按下时深蓝色
                    opacity: createBtn.down ? 0.9 : 1.0
                }

                contentItem: Text {
                    text: createBtn.text
                    font: createBtn.font
                    color: "white"
                    horizontalAlignment: Text.AlignHCenter
                    verticalAlignment: Text.AlignVCenter
                }

                onClicked: {
                    root.createMeeting()  // 调用创建会议功能
                }
            }

            // 加入会议按钮
            Button {
                id: joinBtn
                Layout.fillWidth: true
                text: qsTr("加入会议")
                font.pixelSize: 16
                font.weight: Font.Medium
                padding: 15

                // 绿色按钮样式
                background: Rectangle {
                    radius: 8
                    color: joinBtn.down ? "#27ae60" : "#2ecc71"  // 按下时深绿色
                }

                contentItem: Text {
                    text: joinBtn.text
                    font: joinBtn.font
                    color: "white"
                    horizontalAlignment: Text.AlignHCenter
                    verticalAlignment: Text.AlignVCenter
                }

                onClicked: {
                    root.showConnectScreen()  // 切换到连接服务器界面
                }
            }
        }

        // 当前用户信息显示
        Text {
            Layout.alignment: Qt.AlignHCenter
            text: qsTr("当前用户: ") + root.nowIp  // 显示当前IP地址
            font.pixelSize: 14
            color: "#7f8c8d"
        }
    }
}
